/*******************************************************************************
* Copyright (c) 2010, 2018 西安秦晔信息科技有限公司
* Licensed under the Apache License, Version 2.0 (the "License");
*    you may not use this file except in compliance with the License.
*    You may obtain a copy of the License at
*
*       http://www.apache.org/licenses/LICENSE-2.0
*
*    Unless required by applicable law or agreed to in writing, software
*    distributed under the License is distributed on an "AS IS" BASIS,
*    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*    See the License for the specific language governing permissions and
*    limitations under the License.
*******************************************************************************/
package com.qinyeit.serviceapp.entity;

import com.qinyeit.serviceapp.entity.enums.CreateSourceType;
import com.qinyeit.serviceapp.entity.enums.Gender;
import com.qinyeit.serviceapp.entity.enums.State;
import com.qinyetech.springstage.core.entity.AbstractEntity;

import javax.persistence.*;
import javax.validation.constraints.NotEmpty;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Builder;
import lombok.experimental.Tolerate;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;

/**
 * ClassName: Member <br/>
 * Function: 会员信息 <br/>
 * date: 2018-12-04 11:16:11 <br/>
 *
 * @author liuwenjin
 * @version  1.0
 * @since JDK 1.8
 */
@Builder
@Entity
@Table(name="members")
public class Member extends MerchantGroupBaseEntity<Long> {

	private static final long serialVersionUID = 1L;

	// 手机号 
    @Column(name="phone", length = 300)
	private String phone = null;

	// 姓名 
    @Column(name="name", length = 300)
	private String name = null;

	// 性别 
    @Column(name="gender", length = 300)
	@Enumerated(EnumType.STRING)
	private Gender gender = Gender.MAN;

	// 证件号码 
    @Column(name="card_no", length = 300)
	private String cardNo = null;

	// 出生日期类型 
    @Column(name="birthday_type", length = 300)
	private String birthdayType = null;

	// 出生日期 
	@JSONField(format="yyyy-MM-dd")
    @DateTimeFormat(pattern="yyyy-MM-dd")
    @Column(name="birthday")
	private Date birthday = null;

	// 办卡来源 总部导入
//    @Column(name="source", length = 300)
//	@Enumerated(EnumType.STRING)
	private String source = "";

	// 总消费次数 
    @Column(name="consume_count")
	private Integer consumeCount = 0;

	// 总消费金额 
    @Column(name="consume_amount",scale=2)
	private Double consumeAmount = 0d;

	// 最后消费时间 
	@JSONField(format="yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm")
    @Column(name="consume_time")
	private Date consumeTime = null;

	// 会员状态 
    @Column(name="state", length = 300)
	@Enumerated(EnumType.STRING)
	private State state = State.NORMAL;

    @Column(name = "branch_name",length = 300)
    private String branchName = "";

    //保持和单店的会员信息一直
	@Column(name = "uuid",length = 300)
	private String uuid = "";

    //持卡数量
    @Transient
	private Long count = null;


    @Tolerate
	public Member() {
		
	}
    @Tolerate
	public Member(Long id){
    	super.setId(id);
    }

	public String getUuid() {
		return uuid;
	}

	public void setUuid(String uuid) {
		this.uuid = uuid;
	}

	public Long getCount() {
		return count;
	}

	public void setCount(Long count) {
		this.count = count;
	}

	public String getBranchName() {
		return branchName;
	}

	public void setBranchName(String branchName) {
		this.branchName = branchName;
	}

	/**
	 * 获取手机号
	 */
	public String getPhone() {
		return this.phone;
	}

    /**
     * 设置手机号
     */
	public Member setPhone(String phone) {
		this.phone = phone;
		return this;
	}

	/**
	 * 获取姓名
	 */
	public String getName() {
		return this.name;
	}

    /**
     * 设置姓名
     */
	public Member setName(String name) {
		this.name = name;
		return this;
	}

	/**
	 * 获取证件号码
	 */
	public String getCardNo() {
		return this.cardNo;
	}

    /**
     * 设置证件号码
     */
	public Member setCardNo(String cardNo) {
		this.cardNo = cardNo;
		return this;
	}

	/**
	 * 获取出生日期类型
	 */
	public String getBirthdayType() {
		return this.birthdayType;
	}

    /**
     * 设置出生日期类型
     */
	public Member setBirthdayType(String birthdayType) {
		this.birthdayType = birthdayType;
		return this;
	}

	/**
	 * 获取出生日期
	 */
	public Date getBirthday() {
		return this.birthday;
	}

    /**
     * 设置出生日期
     */
	public Member setBirthday(Date birthday) {
		this.birthday = birthday;
		return this;
	}


	/**
	 * 获取总消费次数
	 */
	public Integer getConsumeCount() {
		return this.consumeCount;
	}

    /**
     * 设置总消费次数
     */
	public Member setConsumeCount(Integer consumeCount) {
		this.consumeCount = consumeCount;
		return this;
	}

	/**
	 * 获取总消费金额
	 */
	public Double getConsumeAmount() {
		return this.consumeAmount;
	}

    /**
     * 设置总消费金额
     */
	public Member setConsumeAmount(Double consumeAmount) {
		this.consumeAmount = consumeAmount;
		return this;
	}

	/**
	 * 获取最后消费时间
	 */
	public Date getConsumeTime() {
		return this.consumeTime;
	}

    /**
     * 设置最后消费时间
     */
	public Member setConsumeTime(Date consumeTime) {
		this.consumeTime = consumeTime;
		return this;
	}

	public Gender getGender() {
		return gender;
	}

	public void setGender(Gender gender) {
		this.gender = gender;
	}

	public String getSource() {
		return source;
	}

	public void setSource(String source) {
		this.source = source;
	}

	public State getState() {
		return state;
	}

	public void setState(State state) {
		this.state = state;
	}
}
